// 获取 code
export function getCode() {
  return new Promise((resolve, reject) => {
    wx.login({
      success: (res) => {
        resolve(res.code);
      },
      fail: (error) => {
        reject(error);
      },
    });
  });
}

// 简洁版本的 http 请求
export function http(config) {
  return new Promise((resolve, reject) => {
    wx.request({
      ...config,
      success: (res) => {
        resolve(res.data);
      },
      fail: (error) => {
        reject(error);
      },
    });
  });
}
